#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import datetime
from ._base import db


class ModalType(db.Model):
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))


class TouguProduct(db.Model):
    """投顾产品
    """
    id = db.Column(db.Integer, primary_key=True)
    modal_id = db.Column(db.Integer, db.ForeignKey('modal_type.id'))
    modal = db.relationship('ModalType', backref=db.backref('modal_products', lazy='dynamic'))
    name = db.Column(db.String(100), default='')
    create_time = db.Column(db.DateTime, default=datetime.datetime.now)

class TouguProductData(db.Model):
    """投顾产品数据
    名称，周盈利,产品编号，全部名称，分类，品种，平台，周期，适用合约，最大回撤，胜算率，年度收益率，每次盈利，每次亏损，已订购，已跟踪，当月盈利,上线时间，评定
    """

    id = db.Column(db.Integer, primary_key=True)
    product_id = db.Column(db.Integer, db.ForeignKey('tougu_product.id'))
    product = db.relationship('TouguProduct', backref=db.backref('modal_product_datas', lazy='dynamic'))
    excel_file = db.Column(db.String(50), default='')
    week_income = db.Column(db.String(10), default='')
    code = db.Column(db.String(20), default='')
    full_name = db.Column(db.String(50), default='')
    type = db.Column(db.String(50), default='')
    variety = db.Column(db.String(50), default='')
    platform = db.Column(db.String(50), default='')
    cycle = db.Column(db.String(10), default='')
    contract = db.Column(db.String(20), default='')
    max_return = db.Column(db.String(10), default='')
    win_odds = db.Column(db.String(10), default='')
    year_income = db.Column(db.String(10), default='')
    once_average_lost = db.Column(db.String(10))
    once_average_income = db.Column(db.String(10))
    month_income = db.Column(db.String(10))
    is_ordered = db.Column(db.String(10),default='')
    is_followed = db.Column(db.String(10), default='')
    online_time = db.Column(db.DateTime, default=datetime.datetime.now)
    desc = db.Column(db.Text, default='')
    create_time = db.Column(db.DateTime, default=datetime.datetime.now)


class Product(db.Model):
    """产品"""
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))
    image = db.Column(db.String(50))
    url = db.Column(db.String(100))
    year_income = db.Column(db.String(10))
    win_odds = db.Column(db.String(10))
    month_income = db.Column(db.String(10))
    once_average_income = db.Column(db.String(10))
    max_return = db.Column(db.String(10))
    once_average_lost = db.Column(db.String(10))

    def __repr__(self):
        return '<Product %s>' % self.name


class Zhuzibao(db.Model):
    """注资宝"""
    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(100))
    image = db.Column(db.String(50))
    desc = db.Column(db.Text)
    price1 = db.Column(db.Integer)
    price2 = db.Column(db.Integer)
    price3 = db.Column(db.Integer)
    def __repr__(self):
        return '<Zhuzibao %s>' % self.name